package demo.service;

import com.alibaba.excel.EasyExcel;
import demo.model.*;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


/**
 * @author ：jiangHaoTing
 * @date ：2025/3/6 11:23
 */
@Component
public class PriceService {



    public static void main(String[] args) {
        String imgStr = "的向幸福出发<br />\n" +
                "<img\n" +
                "  src=\"https://file.leke.cn/webapp/2025-04-22/LZ/ABH8/G5ROT8HK75E2ZDRKAKUHKBVQZ7CHA4.png\" style=\"width: 960.0px;height: 720.0px;\" />\n" +
                "<br />";
        List<String> list = getImgSrc(imgStr);
        String regex = "<img\\s+[^>]*src\\s*=\\s*[\"']([^\"']+)[\"'][^>]*>";
        String[] strs = imgStr.split(regex);
        for(String s:strs) {
            System.out.println(s+"===");
        }
        for (String s : list) {
            System.out.println(s);
        }
    }


    public static List<String> getImgSrc(String content){
        List<String> list = new ArrayList<String>();
        Pattern p_img = Pattern.compile("<(img|IMG)(.*?)(/>|></img>|>)");
        Matcher m_img = p_img.matcher(content);
        boolean result_img = m_img.find();
        if (result_img) {
            while (result_img) {
                //获取到匹配的<img />标签中的内容
                String str_img = m_img.group(2);
                //开始匹配<img />标签中的src
                Pattern p_src = Pattern.compile("(src|SRC)=(\"|\')(.*?)(\"|\')");
                Matcher m_src = p_src.matcher(str_img);
                if (m_src.find()) {
                    String str_src = m_src.group(3);
                    list.add(str_src);
                }
                //结束匹配<img />标签中的src
                //匹配content中是否存在下一个<img />标签，有则继续以上步骤匹配<img />标签中的src
                result_img = m_img.find();
            }
        }
        return list;
    }


//    public static void main(String[] args) {
//        String S  = "";
//
//        S = "DD<img src=\"https://file.leke.cn/note/2025-04-15/DP/RWT5/JZUYV78KICKK1258B3AZCXN13IRCRR.jpg\" style=\"width:398px;height:392px;\" alt=\"\" />试试";
//        S = NoteStringUtils.replaceUtf8mb4(S);
//        System.out.println(S);
//        S = NoteUtils.getFirstImgUrl(S);
//        System.out.println(S);
//    }

    private static Map<String, String> hashMap = new HashMap<>();

    static {
        hashMap.put("A0020", "4.5");
        hashMap.put("A051", "6.8");
        hashMap.put("A0021", "4.5");
        hashMap.put("A0040", "4.5");
        hashMap.put("A54", "18.0");
        hashMap.put("A0022", "4.5");
        hashMap.put("A0039", "4.5");
        hashMap.put("C21", "4.5");
        hashMap.put("A053", "14.0");
        hashMap.put("A052", "6.8");
        hashMap.put("A0082", "19.5");
        hashMap.put("C20", "4.5");
        hashMap.put("C0029", "4.5");
        hashMap.put("A0054", "17.5");
        hashMap.put("A0078", "10.8");
        hashMap.put("A0085", "19.5");
        hashMap.put("A0052", "6.8");
        hashMap.put("A0081", "19.5");
        hashMap.put("A0077", "10.8");
        hashMap.put("A0086", "19.5");
        hashMap.put("A0084", "19.5");
        hashMap.put("C0020", "4.5");
        hashMap.put("C0022", "4.5");
        hashMap.put("A34", "7.5");
        hashMap.put("A0087", "19.0");
        hashMap.put("B0040", "4.5");
        hashMap.put("C0021", "4.5");
        hashMap.put("A33", "7.5");
        hashMap.put("A0023", "4.5");
        hashMap.put("A35", "7.5");
        hashMap.put("A0035", "7.5");
        hashMap.put("B0020", "4.5");
        hashMap.put("A0037", "14.0");

        hashMap.put("A0033", "7.5");
        hashMap.put("A0026", "12.2");
        hashMap.put("B0022", "4.5");
        hashMap.put("B0021", "4.5");
        hashMap.put("A22", "4.5");
        hashMap.put("A35", "7.5");
        hashMap.put("A0038", "14");
        hashMap.put("A0049", "7");
        hashMap.put("A28", "5");
        hashMap.put("A0024", "8");
        hashMap.put("A0005", "2.55");
        hashMap.put("A0025", "11");
        hashMap.put("A23", "4.5");
        hashMap.put("A0046", "3");
        hashMap.put("B29", "5");
        hashMap.put("B0041", "9.4");
        hashMap.put("A0028", "5");

        hashMap.put("C30", "4.5");
        hashMap.put("C22", "4.5");
        hashMap.put("C24", "4.5");
        hashMap.put("C23", "4.5");
        hashMap.put("C26", "9");
        hashMap.put("C25", "9");
        hashMap.put("C28", "9");
        hashMap.put("C27", "9");
        hashMap.put("C29", "9");
        hashMap.put("C0028", "4.5");
        hashMap.put("A0092", "6.15");
        hashMap.put("B0039", "4.5");
        hashMap.put("A0093", "6.15");
        hashMap.put("B0029", "4.5");
        hashMap.put("A0094", "12.3");
        hashMap.put("A0083", "19.5");
        hashMap.put("A0095", "12.3");
        hashMap.put("A0051", "6.8");

























    }


    public void parseExcel(MultipartFile file) throws IOException {
//        // 使用 EasyExcel 读取 Excel 文件
//        List<Fangkuan> fangkuans = EasyExcel.read(file.getInputStream())
//                .head(Fangkuan.class) // 指定数据模型类
//                .sheet() // 读取第一个工作表
//                .doReadSync();// 同步读取
//        list.addAll(fangkuans.stream().filter(a->!StringUtils.isEmpty(a.getCode())).collect(Collectors.toList()));
    }



    public Map<String,String> parseExcel2(MultipartFile fangkuanFile) throws IOException {
        List<Fangkuan> list = new ArrayList<>();
        // 使用 EasyExcel 读取 Excel 文件
        List<Fangkuan> chengBen = EasyExcel.read(fangkuanFile.getInputStream())
                .head(Fangkuan.class) // 指定数据模型类
                .sheet() // 读取第一个工作表
                .doReadSync();// 同步读取
        chengBen = chengBen.stream().filter(a->!StringUtils.isEmpty(a.getCode())).collect(Collectors.toList());

        BigDecimal price5 = new BigDecimal("0");
        Integer num = 0;
        Set<String> set = new HashSet<>();
        for (Fangkuan chenben : chengBen) {
            num += chenben.getNum();
            if(hashMap.get(chenben.getCode())== null){
                set.add(chenben.getCode());
//                System.out.println(chenben.getCode());
                continue;
            }
            //成本
            price5 = price5.add(new BigDecimal(hashMap.get(chenben.getCode())).multiply(new BigDecimal(chenben.getNum())));
        }


        Map<String,String> map = new HashMap<>();
        map.put("成本", price5.toString());
        map.put("数量",  num.toString());
        for (String s: set) {
            System.out.println(s);
        }

        return map;
    }



    public Map<String,String> parseExcel22(MultipartFile ShouzhimingxiFile, MultipartFile fangkuanFile) throws IOException {
        List<Fangkuan> list = new ArrayList<>();
        List<Shouzhimingxi> list2 = new ArrayList<>();
        // 使用 EasyExcel 读取 Excel 文件
        List<Fangkuan> fangkuans2 = EasyExcel.read(fangkuanFile.getInputStream())
                .head(Fangkuan.class) // 指定数据模型类
                .sheet() // 读取第一个工作表
                .doReadSync();// 同步读取
        list.addAll(fangkuans2.stream().filter(a->!StringUtils.isEmpty(a.getCode())).collect(Collectors.toList()));

        // 使用 EasyExcel 读取 Excel 文件
        list2.addAll(EasyExcel.read(ShouzhimingxiFile.getInputStream())
                .head(Shouzhimingxi.class) // 指定数据模型类
                .sheet() // 读取第一个工作表
                .doReadSync());// 同步读取

        list2.forEach(l-> l.setPrice(l.getPrice().replace("CN￥ ","")));
        list2 = list2.stream().filter(a-> !StringUtils.isEmpty(a.getOrderId())).collect(Collectors.toList());
        Map<String, List<Fangkuan>> fangkuanMap = list.stream().collect(Collectors.groupingBy(a-> a.getOrderId()+","+a.getCode()));
        BigDecimal price = new BigDecimal("0");
        BigDecimal price2 = new BigDecimal("0");
        BigDecimal price3 = new BigDecimal("0");
        BigDecimal price4 = new BigDecimal("0");
        BigDecimal price5 = new BigDecimal("0");
        Integer num = 0;
        BigDecimal chenbenPrice = new BigDecimal("0");
        for (Map.Entry<String, List<Fangkuan>> entrySet : fangkuanMap.entrySet()) {
            String order = entrySet.getKey().split(",")[0];
            List<Fangkuan> fangkuans = entrySet.getValue();
            //单个订单=已放款金额-交易佣金-半托管发货物流费-成本*数量-退款+交易佣金退回+半托管赔付
            for (Fangkuan fangkuan : fangkuans) {
                if(hashMap.get(fangkuan.getCode()) == null){
                    System.out.println(fangkuan.getCode());
                    continue;
                }
                price2 = price2.add(new BigDecimal(fangkuan.getPrice()));
                price2 = price2.subtract(new BigDecimal(fangkuan.getTraPrice()));
                price = price.add(new BigDecimal(fangkuan.getPrice()));
                price = price.subtract(new BigDecimal(fangkuan.getTraPrice()));
                price3 = price3.add(new BigDecimal(fangkuan.getPrice()));
                price4 = price4.subtract(new BigDecimal(fangkuan.getTraPrice()));
                //成本
                price = price.subtract(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
                chenbenPrice = chenbenPrice.add(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
                price5 = price5.add(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
                num += fangkuan.getNum();
            }
            Shouzhimingxi shouzhimingxi = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("半托管发货物流费")).findFirst().orElse(null);
            if(shouzhimingxi != null){
                price = price.add(new BigDecimal(shouzhimingxi.getPrice()));
            }
            Shouzhimingxi shouzhimingxi2 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("货款收入退款")).findFirst().orElse(null);
            if(shouzhimingxi2!=null){
                price = price.add(new BigDecimal(shouzhimingxi2.getPrice()));
            }
            Shouzhimingxi shouzhimingxi3 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("交易佣金退回")).findFirst().orElse(null);
            if(shouzhimingxi3!=null){
                price = price.add(new BigDecimal(shouzhimingxi3.getPrice()));
            }
            Shouzhimingxi shouzhimingxi4 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("半托管赔付")).findFirst().orElse(null);
            if(shouzhimingxi4!=null){
                price = price.add(new BigDecimal(shouzhimingxi4.getPrice()));
            }
        }
        List<Shouzhimingxi> list3 =
                list2.stream().filter(a-> !a.getPriceType().equals("交易佣金")).filter(a->!a.getPriceType().equals("货款收入"))
                        .filter(a->!a.getPriceType().equals("半托管发货物流费")).filter(a->!a.getPriceType().equals("交易佣金退回"))
                        .filter(a->!a.getPriceType().equals("货款收入退款")).filter(a->!a.getPriceType().equals("半托管赔付")).collect(Collectors.toList());

        //其他各种费用
        BigDecimal bigDecimal = new BigDecimal("0");

        for (Shouzhimingxi shouzhimingxi : list3) {
            bigDecimal = bigDecimal.add(new BigDecimal(shouzhimingxi.getPrice()));
        }
        price = price.add(bigDecimal);
        System.out.println("销售额-扣除手续费:"+ price2);
        System.out.println("销售额-赚的:"+ price);
        Map<String,String>map = new HashMap<>();
        map.put("销售额",price3.toString());
        map.put("销售额-扣除手续费",price2.toString());
        map.put("手续费",price4.toString());
        map.put("赚的",price.toString());
        map.put("成本",chenbenPrice.toString());
        map.put("数量",num.toString());
        return map;
    }



    public Map<String,String> parseExcel3(MultipartFile dingdangailan, MultipartFile shouruzhichu) throws IOException {
        List<Mingxi> list = new ArrayList<>();
        List<Shouzhimingxi> list2 = new ArrayList<>();
        // 使用 EasyExcel 读取 Excel 文件
        List<Mingxi> mingxi = EasyExcel.read(dingdangailan.getInputStream())
                .head(Mingxi.class) // 指定数据模型类
                .sheet() // 读取第一个工作表
                .doReadSync();// 同步读取
        list.addAll(mingxi.stream().filter(a->!StringUtils.isEmpty(a.getCode())).collect(Collectors.toList()));


        // 使用 EasyExcel 读取 Excel 文件
        list2.addAll(EasyExcel.read(shouruzhichu.getInputStream())
                .head(Shouzhimingxi.class) // 指定数据模型类
                .sheet() // 读取第一个工作表
                .doReadSync());// 同步读取

        list2.forEach(l-> l.setPrice(l.getPrice().replace("CN￥ ","")));
        list2 = list2.stream().filter(a-> !StringUtils.isEmpty(a.getOrderId())).collect(Collectors.toList());

        Map<String, List<Mingxi>> fangkuanMap = list.stream().collect(Collectors.groupingBy(a-> a.getOrderId()+","+a.getCode()));
        //单个订单赚瞬
        BigDecimal zhuanshun = new BigDecimal("0");
        //成本
        BigDecimal chenBen = new BigDecimal("0");
        //运费
        BigDecimal yunfei = new BigDecimal("0");
        //销售额
        BigDecimal xiaoshoue = new BigDecimal("0");

        //yongjin
        BigDecimal yongjin = new BigDecimal("0");
        //交易服务费
        BigDecimal fuwufei = new BigDecimal("0");
        Integer meiyouyunfnum2 = 0;
        //没有计算运费的成交金额
        BigDecimal meiyouyun = new BigDecimal("0");



        Integer num = 0;
        BigDecimal chenbenPrice = new BigDecimal("0");
        Map<String, List<Mingxi>> fangkuanMap2 = list.stream().collect(Collectors.groupingBy(a-> a.getOrderId()));

        for (Map.Entry<String, List<Mingxi>> entrySet : fangkuanMap2.entrySet()) {
            String order = entrySet.getKey();
            List<Mingxi> fangkuans = entrySet.getValue();
            //单个订单=已放款金额-交易佣金-半托管发货物流费-成本*数量-退款+交易佣金退回+半托管赔付
            BigDecimal meiyouyun1 = new BigDecimal("0");
            for (Mingxi fangkuan : fangkuans) {
                if(hashMap.get(fangkuan.getCode()) == null){
                    System.out.println(fangkuan.getCode());
                    continue;
                }
                Shouzhimingxi shouzhimingxi = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("巴西洲税（半托管订单）")).findFirst().orElse(null);
                if(shouzhimingxi != null){
                    if(shouzhimingxi.getPrice().equals(fangkuan.getPrice())){
                        continue;
                    }
                }
                Shouzhimingxi shouzhimingxi2 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("巴西关税（半托管订单）")).findFirst().orElse(null);
                if(shouzhimingxi2 != null){
                    if(shouzhimingxi2.getPrice().equals(fangkuan.getPrice())){
                        continue;
                    }
                }
                num += fangkuan.getNum();
                xiaoshoue = xiaoshoue.add(new BigDecimal(fangkuan.getPrice()));
                //销售额计算
                zhuanshun = zhuanshun.add(new BigDecimal(fangkuan.getPrice()));
                meiyouyun1 = meiyouyun1.add(new BigDecimal(fangkuan.getPrice()));
                //减去成本
                zhuanshun = zhuanshun.subtract(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
                chenBen = chenBen.add(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
            }
            Shouzhimingxi shouzhimingxi0 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("佣金")).findFirst().orElse(null);
            if(shouzhimingxi0!=null){
                yongjin = yongjin.add(new BigDecimal(shouzhimingxi0.getPrice()));
                zhuanshun = zhuanshun.add(new BigDecimal(shouzhimingxi0.getPrice()));
            }else {
                System.out.println(order+"订单没有计算佣金");
            }
            Shouzhimingxi shouzhimingxi2 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("交易服务费")).findFirst().orElse(null);
            if(shouzhimingxi2!=null){
                fuwufei  = fuwufei.add(new BigDecimal(shouzhimingxi2.getPrice()));
                zhuanshun = zhuanshun.add(new BigDecimal(shouzhimingxi2.getPrice()));
            }else {
                System.out.println(order+"交易服务费");
            }
            Shouzhimingxi shouzhimingxi = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("半托管发货物流费")).findFirst().orElse(null);
            if(shouzhimingxi != null){
                zhuanshun = zhuanshun.add(new BigDecimal(shouzhimingxi.getPrice()));
                yunfei = yunfei.add(new BigDecimal(shouzhimingxi.getPrice()));
            }else {
                meiyouyunfnum2++;
                meiyouyun = meiyouyun1.add(meiyouyun);
                System.out.println(order+"半托管发货物流费");
            }

            Shouzhimingxi shouzhimingxi4 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("半托管赔付")).findFirst().orElse(null);
            if(shouzhimingxi4!=null){
                zhuanshun = zhuanshun.add(new BigDecimal(shouzhimingxi4.getPrice()));
            }
        }
//        List<Shouzhimingxi> list3 =
//                list2.stream().filter(a-> !a.getPriceType().equals("交易佣金")).filter(a->!a.getPriceType().equals("货款收入"))
//                        .filter(a->!a.getPriceType().equals("半托管发货物流费")).filter(a->!a.getPriceType().equals("交易佣金退回"))
//                        .filter(a->!a.getPriceType().equals("货款收入退款")).filter(a->!a.getPriceType().equals("半托管赔付")).collect(Collectors.toList());
//
//        //其他各种费用
//        BigDecimal bigDecimal = new BigDecimal("0");
//
//        for (Shouzhimingxi shouzhimingxi : list3) {
//            bigDecimal = bigDecimal.add(new BigDecimal(shouzhimingxi.getPrice()));
//        }
//        price = price.add(bigDecimal);
//        System.out.println("销售额-扣除手续费:"+ price2);
//        System.out.println("销售额-赚的:"+ price);
        Map<String,String>map = new HashMap<>();
//        map.put("销售额",price3.toString());
//        map.put("销售额-扣除手续费",price2.toString());
//        map.put("手续费",price4.toString());
        map.put("赚的",zhuanshun.toString());
        map.put("成本",chenBen.toString());
        map.put("运费",yunfei.toString());
        map.put("销售额",xiaoshoue.toString());
        map.put("销售数量",num.toString());
        map.put("交易服务费",fuwufei.toString());
        map.put("佣金",yongjin.toString());
        map.put("没有计算运费的订单数",meiyouyunfnum2.toString());
        map.put("没有计算运费的订单交易额度",meiyouyun.toString());
//        map.put("成本",chenbenPrice.toString());
//        map.put("数量",num.toString());
        return map;
    }



    public Map<String,String> parseExcel2222(MultipartFile ShouzhimingxiFile, MultipartFile fangkuanFile) throws IOException {
        List<Fangkuan> list = new ArrayList<>();
        List<Shouzhimingxi> list2 = new ArrayList<>();
        // 使用 EasyExcel 读取 Excel 文件
        List<Fangkuan> fangkuans2 = EasyExcel.read(fangkuanFile.getInputStream())
                .head(Fangkuan.class) // 指定数据模型类
                .sheet() // 读取第一个工作表
                .doReadSync();// 同步读取
        list.addAll(fangkuans2.stream().filter(a->!StringUtils.isEmpty(a.getCode())).collect(Collectors.toList()));

        // 使用 EasyExcel 读取 Excel 文件
        list2.addAll(EasyExcel.read(ShouzhimingxiFile.getInputStream())
                .head(Shouzhimingxi.class) // 指定数据模型类
                .sheet() // 读取第一个工作表
                .doReadSync());// 同步读取

        list2.forEach(l-> l.setPrice(l.getPrice().replace("CN￥ ","")));
        list2 = list2.stream().filter(a-> !StringUtils.isEmpty(a.getOrderId())).collect(Collectors.toList());
        Map<String, List<Fangkuan>> fangkuanMap = list.stream().collect(Collectors.groupingBy(a-> a.getOrderId()+","+a.getCode()));
        BigDecimal price = new BigDecimal("0");
        BigDecimal price2 = new BigDecimal("0");
        BigDecimal price3 = new BigDecimal("0");
        BigDecimal price4 = new BigDecimal("0");
        BigDecimal price5 = new BigDecimal("0");
        BigDecimal chenbenPrice = new BigDecimal("0");
        Integer num = 0;

        Map<String, List<Fangkuan>> fangkuanMap2 = list.stream().collect(Collectors.groupingBy(a-> a.getOrderId()));

        for (Map.Entry<String, List<Fangkuan>> entrySet : fangkuanMap2.entrySet()) {
            String order = entrySet.getKey();
            List<Fangkuan> fangkuans = entrySet.getValue();
            //单个订单=已放款金额-交易佣金-半托管发货物流费-成本*数量-退款+交易佣金退回+半托管赔付
            for (Fangkuan fangkuan : fangkuans) {
                if(hashMap.get(fangkuan.getCode()) == null){
                    System.out.println(fangkuan.getCode());
                    continue;
                }
                price2 = price2.add(new BigDecimal(fangkuan.getPrice()));
                price2 = price2.subtract(new BigDecimal(fangkuan.getTraPrice()));
                price = price.add(new BigDecimal(fangkuan.getPrice()));
                price = price.subtract(new BigDecimal(fangkuan.getTraPrice()));
                price3 = price3.add(new BigDecimal(fangkuan.getPrice()));
                price4 = price4.subtract(new BigDecimal(fangkuan.getTraPrice()));
                //成本
                price = price.subtract(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
                chenbenPrice = chenbenPrice.add(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
                price5 = price5.add(new BigDecimal(hashMap.get(fangkuan.getCode())).multiply(new BigDecimal(fangkuan.getNum())));
                num += fangkuan.getNum();
            }
            Shouzhimingxi shouzhimingxi = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("半托管发货物流费")).findFirst().orElse(null);
            if(shouzhimingxi != null){
                price = price.add(new BigDecimal(shouzhimingxi.getPrice()));
            }
            Shouzhimingxi shouzhimingxi2 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("货款收入退款")).findFirst().orElse(null);
            if(shouzhimingxi2!=null){
                price = price.add(new BigDecimal(shouzhimingxi2.getPrice()));
            }
            Shouzhimingxi shouzhimingxi3 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("交易佣金退回")).findFirst().orElse(null);
            if(shouzhimingxi3!=null){
                price = price.add(new BigDecimal(shouzhimingxi3.getPrice()));
            }
            Shouzhimingxi shouzhimingxi4 = list2.stream().filter(a-> order.equals(a.getOrderId()) && a.getPriceType().equals("半托管赔付")).findFirst().orElse(null);
            if(shouzhimingxi4!=null){
                price = price.add(new BigDecimal(shouzhimingxi4.getPrice()));
            }
        }
        List<Shouzhimingxi> list3 =
                list2.stream().filter(a-> !a.getPriceType().equals("交易佣金")).filter(a->!a.getPriceType().equals("货款收入"))
                        .filter(a->!a.getPriceType().equals("半托管发货物流费")).filter(a->!a.getPriceType().equals("交易佣金退回"))
                        .filter(a->!a.getPriceType().equals("货款收入退款")).filter(a->!a.getPriceType().equals("半托管赔付")).collect(Collectors.toList());

        //其他各种费用
        BigDecimal bigDecimal = new BigDecimal("0");

        for (Shouzhimingxi shouzhimingxi : list3) {
            bigDecimal = bigDecimal.add(new BigDecimal(shouzhimingxi.getPrice()));
        }
        price = price.add(bigDecimal);
        System.out.println("销售额-扣除手续费:"+ price2);
        System.out.println("销售额-赚的:"+ price);
        Map<String,String>map = new HashMap<>();
        map.put("销售额",price3.toString());
        map.put("销售额-扣除手续费",price2.toString());
        map.put("手续费",price4.toString());
        map.put("赚的",price.toString());
        map.put("成本",chenbenPrice.toString());
        map.put("数量",num.toString());
        return map;
    }





}
